<template>
	<view class="commentList">
		<block v-if="isHasDataFlag">
			<view class="listItem"
				v-for="(item,index) in askList"
				:key="index"
			>
				<view class="quesWrap">
					<view class="ansQuesTit multiEllip clamp2">{{item.askTitle}}</view>
					<view class="listItemTop hasFlex">
						<view class="itemImg hasFlex">
							<view class="headImg"> 
								<image v-if="item.askUserPortrait == ''" class="samePar" src="../../../static/images/defHead.png"></image>
								<image v-else class="samePar" :src="getCloudFilePath(item.askUserPortrait)"></image>
							</view>
							<view class="usename specCol">{{item.askNickName == '' ? '匿名用户' : item.askNickName}}</view>
						</view>
						<view class="topRight time">{{item.askAddTime}}</view>
					</view>
					<view class="itemCon specCol"><jyf-parser :html="item.askContent" :selectable="true"></jyf-parser></view>
				</view>
				<view class="ansWrap">
					<view class="ansCon"><text class="jd">解答:</text><jyf-parser :html="item.ackContent" :selectable="true"></jyf-parser></view>
					<view class="ansTime">{{item.ackAddTime}}</view>
				</view>
			</view>
			<loading-view :loading="loading"></loading-view>
		</block>
		<block v-else-if="isHasDataFlag == false">
			<no-data></no-data>
		</block>
	</view>
</template>

<script>
	import jyfParser from "@/components/jyf-parser/jyf-parser";
	import { getZxsAnsQueList } from '@/api/xlzx/index'
	export default {
		components:{
			jyfParser
		},
		data(){
			return{
				zxsUserId:'',
				nowPage:1,
				loading:false,
				askList:[],
				isHasDataFlag:null
			}
		},
		onLoad(options){
			this.zxsUserId = options.zxsUserId;
			this.loadZxsJdList();
		},
		onPullDownRefresh : function(){
			this.initParams();
			uni.stopPullDownRefresh();
		},
		onReachBottom : function(){
			if( !this.loading ){
				this.loadZxsJdList();
			}
		},
		methods:{
			loadZxsJdList(){
				let { nowPage,askList } = this;
				this.loading = true;
				var field = { userId:this.zxsUserId,page:this.nowPage,limit:this.limit };
				getZxsAnsQueList(field).then(res=>{
					nowPage += 1;
					askList.push( ...res.data.datas );
					this.askList = askList;
					this.nowPage = nowPage;
					this.loading = false;
					this.isHasDataFlag = true;
				}).catch(err=>{
					console.log(err)
					if(err.data.code == 50001){
						this.loading = false;
						this.isHasDataFlag=false;
					}
				});
			},
			initParams(){
				this.nowPage = 1;
				this.loading = false;
				this.askList = [];
				this.loadZxsJdList();
			}
		}
	}
</script>
<style lang="scss">
	page{
		background: $pss-bg-primary;
		margin-top: 30rpx;
	}
</style>
<style lang='scss' scoped>
	@import '@/static/scss/zxsPj.scss';
	.commentList{
		padding: 0 30rpx;
		.listItem{
			border-bottom: none;
			padding: 0;
			margin-bottom: 30rpx;
			.quesWrap{
				border-radius: 20rpx 20rpx 0 0;
				background: #fff;
				padding: 20rpx;
			}
			.ansQuesTit{
				font-size: 36rpx;
				color: $pss-text-color3;
				font-weight: bold;
			}
			.usename.specCol{
				color: $pss-text-color3 !important;
			}
			.topRight.time{
				font-size: $font-size24;
				color: $pss-text-color8;
			}
			.itemCon.specCol{
				color: $pss-text-color8;
			}
			.ansWrap{
				border-radius: 0 0 20rpx 20rpx;
				background: #f2fdf9;
				padding: 20rpx;
				.ansCon{
					font-size: $font-size30;
					color:$pss-text-color3;
					line-height: 50rpx;
					.jd{
						color:$pss-color-green;
						font-weight: bold;
						margin-right: 5rpx;
					}
				}
				.ansTime{
					font-size: $font-size24;
					color:$pss-text-color8;
					margin-top: 10rpx;
				}
			}
		}
	}
</style>